@layout("/common/_container.html"){
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal" id="isDealInfoForm">
            <div style="display: none">
                <input type="hidden" id="customerId" value="${customerId}">
                <input type="hidden" id="reservationsId" value="${consultantInfo.reservationsId}">
                <input type="hidden" id="medicalRecordNumber" value="${consultantInfo.medicalRecordNumber}">
                <input type="hidden" id="customerName" value="${consultantInfo.customerName}">
                <textarea id="arrearsRemarks" name="arrearsRemarks" rows=12 cols=150></textarea>
                <input id="arrears" value="0">
                <input id="totleFoldingPays" value="">
            </div>
            <div class="row">
                <div class="col-sm-3">
                    <#NameCon id="payServiceNames" name="收费项目名称" />
                </div>
                <div class="col-sm-3">
                    <#NameCon id="payServicePrices" name="价格" />
                </div>
                <div class="col-sm-2">
                    <div class="search_bt" onclick="IsDealInfoDlg.search()">搜索</div>
                </div>
                <div class="col-sm-2">
                    <div class="search_bt" onclick="IsDealInfoDlg.resetSearch()">重置</div>
                </div>
            </div>
            <div>
                病历号：${consultantInfo.medicalRecordNumber} &nbsp
                电话：${consultantInfo.customerPhone}&nbsp
                姓名：${consultantInfo.customerName}&nbsp
                性别：${consultantInfo.sex}&nbsp
                年龄：${consultantInfo.customerAge}&nbsp
                现场TC：${consultantInfo.fieldTc}
            </div>
            <div class="row">
                <div class="col-sm-3">
                    <div class="panel-body">
                        科室：
                    </div>
                    <div style="width:500px;height:240px;overflow:auto;" class="panel panel-success sortRight">
                        <#sortPayService  id="sortPayService" list="${payServiceInfoList}"/>
                    </div>
                </div>

                <div class="col-sm-3">
                    <div class="row">
                        <div class="panel-body">
                            一级项目：
                        </div>
                        <div id="firstLevelProjectDiv" style="width:500px;height:240px;overflow:auto;"
                             class="panel panel-success sortRight">
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="row">
                        <div class="panel-body">
                            收费项目：
                        </div>
                        <div id="payServiceName" style="width:500px;height:240px;overflow:auto;"
                             class="panel panel-success sortRight">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div id="detailedListDiv" style="width:1200px;height:300px;overflow:auto;"
                     class="panel panel-success sortRight">
                </div>
                <div class="row btn-group-m-t">
                    <div class="col-sm-3" style="display: none">
                        <input disabled="disabled" id="doctor" name="医生"/>
                        <div class="other_bt" onclick="IsDealInfoDlg.distributiveDoctor()">分配医生</div>
                    </div>
                    <div class="col-sm-10">
                        <#button btnCss="info" name="开单" id="deal" icon="fa-check" clickFun="IsDealInfoDlg.openBill()"/>
                        <#button btnCss="info" name="取消" id="deal" icon="fa-check" clickFun="IsDealInfoDlg.cancelBill()"/>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
</div>
<link rel="stylesheet" href="${ctxPath}/static/css/jqui/jquery-ui.min.css">
<script src="${ctxPath}/static/js/jquery-ui.min.js"></script>
<script src="${ctxPath}/static/modular/tcCenter/consultant/is_deal_info.js"></script>
<script>
    var customerId = document.getElementById("customerId").value;
    $("ul#sortPayService").on("click", "li", function () {
        var department = $(this).text();
        var dc = department + "," + customerId;
        $.ajax({
            url: Feng.ctxPath + "/payService/getFirstLevelProject",
            type: "post",
            data: {
                "dc": dc
            },
            success: function (data) {
                var txt = '';
                for (var i = 0; i < data.length; i++) {
                    txt += ' <div style="display: inline-block;width: 400px"> ' +
                        ' <a href=\"javascript:;\" onclick=\"openFirstLevelProject(\'' + data[i].firstLevelProject + '\')\">&nbsp' + data[i].firstLevelProject + '</a> ' +
                        ' </div>';
                    var customerId = data[i].customerId;
                    var department = data[i].department;
                    openFirstLevelProject = function (firstLevelProject) {
                        var cdf = customerId + "," + department + "," + firstLevelProject;
                        var txts = '';
                        $.ajax({
                            url: Feng.ctxPath + "/payService/getPaySeriveName",
                            type: "post",
                            data: {
                                "cdf": cdf
                            },
                            success: function (data1) {
                                for (var i = 0; i < data1.length; i++) {
                                    txts += ' <div style="display: inline-block;width: 400px"> ' +
                                        ' <a href=\"javascript:;\" onclick=\"openDetails(\'' + data1[i].id + '\')\">&nbsp' + data1[i].payServiceName + '&nbsp' + data1[i].payServicePriceOne + '-' + data1[i].payServicePriceTwo + '元</a> ' +
                                        ' </div>';
                                }
                                document.getElementById('payServiceName').innerHTML = txts;
                            },
                            error: function (data) {
                                alert('内部故障!');
                            }
                        });
                    };
                }
                document.getElementById('firstLevelProjectDiv').innerHTML = txt;
            },
            error: function (data) {
                alert('内部故障!');
            }
        });
    })

    deletePayServices = function (id) {
        $.ajax({
            url: Feng.ctxPath + "/payService/deleteOpenBill",
            type: "post",
            data: {
                "id": id
            },
            success: function (data) {
                var txt = '<ul>';
                var totleReceivable = 0.00;
                var totleFoldingPay = 0.00;
                var customerId = document.getElementById("customerId").value;
                if (data.length == 0) {
                    document.getElementById('detailedListDiv').innerHTML = txt;
                    document.getElementById('totleFoldingPays').value = totleFoldingPay;
                } else {
                    for (var i = 0; i < data.length; i++) {
                        var pnum = data[i].payServiceNum;
                        var psptwo = data[i].payServicePriceTwo;
                        var foldingPay = data[i].foldingPay;
                        totleReceivable += pnum * psptwo.toFixed(2);
                        totleFoldingPay += foldingPay;
                        txt += ' <div class="data_row" style="margin-top: 5px">' +
                            '                <div style=\"padding-left: 10px;width: 120px;display: inline-block;\">\n' +
                            '                    <div style=\"border-bottom: 1px solid;\">\n' +
                            '                        <div style=\"font-size: 12px;display: inline-block;width:55px;border-right: 1px solid black;text-align: right\" id=\"yw_left_top\">' + data[i].leftUp + '</div><!--\n' +
                            '                         --><div style=\"font-size: 12px;display: inline-block;width:55px;\" id=\"yw_right_top\">' + data[i].rightUp + '</div>\n' +
                            '                   </div>\n' +
                            '                    <div>\n' +
                            '                        <div style=\"font-size: 12px;display: inline-block;width:55px;border-right: 1px solid black;text-align: right\" id=\"yw_left_bottom\">' + data[i].leftDown + '</div><!--\n' +
                            '                         --><div style=\"font-size: 12px;display: inline-block;width:55px;\" id=\"yw_right_top\">' + data[i].rightDown + '</div>\n' +
                            '                   </div>\n' +
                            '                </div>\n' +
                            ' ' + data[i].department + '&nbsp;&nbsp;' + data[i].firstLevelProject + '&nbsp;&nbsp;' + data[i].payServiceName + ' &nbsp;&nbsp;' + data[i].payService + '元&nbsp;&nbsp;' + data[i].payServiceNum + data[i].unit + '&nbsp;&nbsp;折后价：' + foldingPay.toFixed(2) + '元&nbsp;&nbsp;医生:' + data[i].doctor +
                            ' <a href=\"javascript:;\" onclick=\"openPayService(\'' + data[i].id + '\')\">&nbsp修改</a> <a href=\"javascript:;\" onclick=\"deletePayServices(\'' + data[i].id + '\')\">&nbsp;&nbsp:删除</a>' +
                            '</div>';
                    }
                    txt += ' <li style="margin-top: 50px">合计&nbsp;&nbsp;&nbsp;折后金额：' + totleFoldingPay.toFixed(2) + ' ' +
                       // ' <a href=\"javascript:;\" onclick=\"openUpdateMoney(\'' + customerId + '\')\">&nbsp修改折后价</a>' +
                        '</li>';
                    txt += '<div id="arrearsOfMoney">&nbsp;&nbsp;实收金额：<input id="serviceActualPay" value="' + totleFoldingPay.toFixed(2) + '"> ';
                    txt += '</ul>';
                    document.getElementById('detailedListDiv').innerHTML = txt;
                    document.getElementById('totleFoldingPays').value = totleFoldingPay;
                }
                Feng.success("删除成功!");
            },
            error: function (data) {
                alert('内部故障!');
            }
        });
    }

    //点击时间框样式变化
    var dom = document.getElementById("sortPayService");
    var domchilds = document.getElementsByClassName("ui-state-default");
    dom.onclick = function (e) {
        var ev = e.event || window.event;
        console.log(domchilds);
        for (var i = 0; i < domchilds.length; i++) {
            domchilds[i].style.borderColor = '#d3d3d3';
        }
        ev.target.style.borderColor = 'red';
    }
    openPayService = function (id) {
        var customerId = document.getElementById("customerId").value;
        var ci = customerId + "," + id;
        var index = layer.open({
            type: 2,
            title: '收费项目详情',
            area: ['90%', '90%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/payService/getPayServiceDetail/' + ci
        });
        this.layerIndex = index;
    };

    openUpdateMoney = function (customerId) {
        var index = layer.open({
            type: 2,
            title: '收费项目详情',
            area: ['90%', '90%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/payService/openUpdateMoney/' + customerId
        });
        this.layerIndex = index;
    };

    openDetails = function (id) {
        var index = layer.open({
            type: 2,
            title: '收费项目详情',
            area: ['90%', '90%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/payService/getPayServiceDetails/' + id
        });
        this.layerIndex = index;
    };
</script>
<style>
    .search_bt, .other_bt {
        cursor: pointer;
        display: inline-block;
        width: 105px;
        height: 27px;
        line-height: 27px;
        color: white;
        text-align: center;
        font-size: 14px;
        border-radius: 20px;
        margin-bottom: 5px;
    }

    .search_bt {
        background: url("${ctxPath}/static/img/x18.png") no-repeat;
        background-size: cover;
    }

    .other_bt {
        background: url("${ctxPath}/static/img/x19.png") no-repeat;
        background-size: cover;
    }

    td a {
        display: block;
        width: 150%;
        position: relative;
        left: -25%;
    }

    .search_bt, .other_bt {
        cursor: pointer;
        display: inline-block;
        width: 105px;
        height: 27px;
        line-height: 27px;
        color: white;
        text-align: center;
        font-size: 14px;
        border-radius: 20px;
        margin-bottom: 5px;
    }

    .search_bt {
        background: url("${ctxPath}/static/img/x18.png") no-repeat;
        background-size: cover;
    }

    .other_bt {
        background: url("${ctxPath}/static/img/x19.png") no-repeat;
        background-size: cover;
    }

    td a {
        display: block;
        width: 150%;
        position: relative;
        left: -25%;
    }
</style>
@}
